﻿using AutoMapper;
using J.Model;
using J.ProductSet.Application.Command.PriceInventoryControlCommand;
using MediatR;
using SqlSugar;

namespace J.ProductSet.Application.CommandHandler.PriceInventoryControlCommandHandler
{
    public class PriceInventoryControlDeleteCommandHandler : IRequestHandler<PriceInventoryControlDeleteCommand, int>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public IMapper _mapper;
        public PriceInventoryControlDeleteCommandHandler(ISqlSugarClient sqlSugarClient, IMapper mapper)
        {
            _sqlSugarClient = sqlSugarClient;
            _mapper = mapper;
        }
        public async Task<int> Handle(PriceInventoryControlDeleteCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Deleteable<PriceInventoryControl>(new PriceInventoryControl() { PriceInventoryID = request.PriceInventoryID }).ExecuteCommandAsync();
        }
    }
}
